<?php
include "general_include.php";
if(!isset($_POST['submit'])){
	include "top.php";
	//include "left.php";
}
$chkoldPass = "SELECT * FROM ".TABLEPREFIX."_user where user_id='".$_SESSION['user_id']."'";
$passArr = $UserManagerObjAjax->GetRecords('Row',$chkoldPass);
   
if(isset($_POST['submit']))
{
   $Formval=$_POST;
   $old_password = $_POST['old_password'];
   $new_password = $_POST['new_password'];
   $conf_password = $_POST['conf_password'];
   $valid=1;
  
   
   if($old_password != $passArr['password'])
   {
      echo $ermsg = 1;
	  $valid=0;
	  exit;
   } 
   
   if($valid==1)
   {
      $updatePass = "UPDATE ".TABLEPREFIX."_user SET password='$new_password' WHERE user_id='".$_SESSION['user_id']."'";
	  $UserManagerObjAjax->Execute($updatePass);
	  if(!mysql_error())
	  {
		  /*echo "<script>window.location.href='profile.php?messg=1'</script>";*/
		  echo "Password Change successfully";
		  exit;
	  }
    
   }
}
$smarty->assign('is_coach',$is_coach);
$smarty->assign('is_partner',$is_partner);
$smarty->assign('user_email',$passArr['email']);
$smarty->assign('Formval',$Formval);
$smarty->assign('ermsg',$ermsg);
$smarty->display('change_password.tpl');
include "footer.php";
?>